<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Http\Requests\CodeRequest;
use App\Http\Requests\UserRequest;
use App\Models\User;
use App\Plugin\AliSms;
use Facade\Ignition\Facades\Flare;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class UserController extends AbsController
{
    /**
     * 获取我的信息
     *
     * @return \Illuminate\Contracts\Auth\Authenticatable
     */
    public function index()
    {

    }

    /**
     * 用户的创建
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * 用户的创建
     * @param UserRequest $request
     * @param User $user
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
     */
    public function store(UserRequest $request,User $user)
    {
       $user->fill($request->all());
       $user->password=Hash::make($request->password);
       $user->save();
       \Auth::login($user);
       return $this->success($user,'恭喜创建用户成功');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 发送短信验证码
     * @param Request $request
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
     * @throws \Exception
     */
    public function sendSms(CodeRequest $request) {
        $sendSms=new AliSms();
//        $sendSms->sendSms($request->phone);
        return $this->success([],'发送短信成功');
    }
}
